Development:Scripting
Guides * How to script in GearHead Useful Files The following files in the doc subdirectory describe the ArenaScript language. * ASL_Reference.txt - includes an introduction. * ASLref.txt - contains a succinct list of commands. * ASL_messages.txt - some details about messages. To dig deeper into the language, take a look at these files in the GameData subdirectory. * aslmacro.txt - command macros * asvmacro.txt - value macros Finally here are source code files that implement the language. * arenascript.pp - the main interpreter * ghchars.pp - constants such as skill IDs * gears.pp - defines the script file locations, for example Series_Directory. Notes for Beginners A few things about the language seem tricky to me. First, the if syntax is generally if-else-then, rather than if-then-else. For example: This says that if V1 is greater than 1, then Say Msg2, otherwise do gotoNotGreater. Also, multiple commands can be written on one line, and there are no parentheses to show which are arguments and where the next part starts. For example: It turns out that ifG takes two parameters and the SkRoll function only takes one parameter. So first, this command passes SkRoll the value 16 (which ghchars.pp shows to be the Medicine skill). Then, it tests if the result of SkRoll is greater than 17 or not. We can picture it like this: ifGreaterThan(SkillRoll(16), 17) then One more thing to understand is that variables are sometimes simply indicated by their number. For example: This says that if V1 equals 0, then set V1 to 2. The "1" here means variable V1. An Example Here is an example that shows how to make changes. We will create a new NPC who hands out money! First, open the main adventure file Series/ADV_FederatedTerritories.txt in a text editor such as Notepad++. Search for the place where it defines Megi. After the line "SetPersona 17," add these lines. NPC Citizen name home rumor chardesc Male Young Cheerful SetTeam 2 SetPersona 500 This defines a new character with the ID of 500. Now find the line that simply contains "Persona 202," which is the section that shows the cook's dialog. After this section, add the following to start the dialog for our new character. Persona 500 greeting Result1 .FreeCashStory Msg1 Msg2 Prompt1 Then, create a new file in the Series folder called PLOT_FreeHandouts.txt with the following contents. Plot 0 name element1 Stat 1 500 sub Persona 1 greeting goAlreadyStarted goAlreadySaidPlease Result1 Result2 Result3 Result4 Result5 Msg1 Msg2 Msg3 Msg4 Msg5 Msg6 Msg7 Prompt1 Prompt2 Prompt3 <$1 would be good.> Prompt4 <$2 is what I need.> Prompt5 <$50 and nothing less!> end Here, the Stat line says that the character with ID 500 will be person number 1 in this script. "Say 1" means show Msg1, "AddChat 1" means give Prompt1 as one of the choices, and "Result1" is what happens if "Prompt1" is selected. To run this example, Start RPG Campaign to create a new character from scratch. Any stats and name will do; there is no need to keep this character. Now go to the Mayor's house in Hogye and talk to EZ Cash.